import 'package:oramemo/generated/json/base/json_convert_content.dart';
import 'package:oramemo/entity/voice_record_transliterate_entity.dart';

VoiceRecordTransliterateEntity $VoiceRecordTransliterateEntityFromJson(
    Map<String, dynamic> json) {
  final VoiceRecordTransliterateEntity voiceRecordTransliterateEntity = VoiceRecordTransliterateEntity();
  final String? text = jsonConvert.convert<String>(json['text']);
  if (text != null) {
    voiceRecordTransliterateEntity.text = text;
  }
  final List<
      VoiceRecordTransliterateSegments>? segments = (json['segments'] as List<
      dynamic>?)?.map(
          (e) =>
      jsonConvert.convert<VoiceRecordTransliterateSegments>(
          e) as VoiceRecordTransliterateSegments).toList();
  if (segments != null) {
    voiceRecordTransliterateEntity.segments = segments;
  }
  final String? language = jsonConvert.convert<String>(json['language']);
  if (language != null) {
    voiceRecordTransliterateEntity.language = language;
  }
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    voiceRecordTransliterateEntity.code = code;
  }
  return voiceRecordTransliterateEntity;
}

Map<String, dynamic> $VoiceRecordTransliterateEntityToJson(
    VoiceRecordTransliterateEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['text'] = entity.text;
  data['segments'] = entity.segments?.map((v) => v.toJson()).toList();
  data['language'] = entity.language;
  data['code'] = entity.code;
  return data;
}

extension VoiceRecordTransliterateEntityExtension on VoiceRecordTransliterateEntity {
  VoiceRecordTransliterateEntity copyWith({
    String? text,
    List<VoiceRecordTransliterateSegments>? segments,
    String? language,
    int? code,
  }) {
    return VoiceRecordTransliterateEntity()
      ..text = text ?? this.text
      ..segments = segments ?? this.segments
      ..language = language ?? this.language
      ..code = code ?? this.code;
  }
}

VoiceRecordTransliterateSegments $VoiceRecordTransliterateSegmentsFromJson(
    Map<String, dynamic> json) {
  final VoiceRecordTransliterateSegments voiceRecordTransliterateSegments = VoiceRecordTransliterateSegments();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    voiceRecordTransliterateSegments.id = id;
  }
  final int? seek = jsonConvert.convert<int>(json['seek']);
  if (seek != null) {
    voiceRecordTransliterateSegments.seek = seek;
  }
  final String? start = jsonConvert.convert<String>(json['start']);
  if (start != null) {
    voiceRecordTransliterateSegments.start = start;
  }
  final String? end = jsonConvert.convert<String>(json['end']);
  if (end != null) {
    voiceRecordTransliterateSegments.end = end;
  }
  final String? text = jsonConvert.convert<String>(json['text']);
  if (text != null) {
    voiceRecordTransliterateSegments.text = text;
  }
  return voiceRecordTransliterateSegments;
}

Map<String, dynamic> $VoiceRecordTransliterateSegmentsToJson(
    VoiceRecordTransliterateSegments entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['seek'] = entity.seek;
  data['start'] = entity.start;
  data['end'] = entity.end;
  data['text'] = entity.text;
  return data;
}

extension VoiceRecordTransliterateSegmentsExtension on VoiceRecordTransliterateSegments {
  VoiceRecordTransliterateSegments copyWith({
    int? id,
    int? seek,
    String? start,
    String? end,
    String? text,
  }) {
    return VoiceRecordTransliterateSegments()
      ..id = id ?? this.id
      ..seek = seek ?? this.seek
      ..start = start ?? this.start
      ..end = end ?? this.end
      ..text = text ?? this.text;
  }
}